"use server";
import "./index.css";
import { Flex, Menu, message } from "antd";
import { getQuestionBankVoByIdUsingGet } from "@/api/questionBankController";
import { getQuestionVoByIdUsingGet } from "@/api/questionController";
import Sider from "antd/es/layout/Sider";
import Title from "antd/es/typography/Title";
import { Content } from "antd/es/layout/layout";
import QuestionBank = API.QuestionBank;
import QuestionCard from "@/app/components/QuestionCard";
import Link from "next/link";

/**
 * 题目详情页
 * @constructor
 */
// @ts-ignore
export default async function QuestionPage({ params }) {
  const { questionBankId, questionId } = params;

  // todo 获取题目详情
  let question = undefined;
  try {
    const res = await getQuestionVoByIdUsingGet({
      id: questionId,
    });
    console.log("当前的题库ID：" + questionBankId);
    // @ts-ignore
    question = res.data;
  } catch (e) {
    // @ts-ignore
    message.error("获取题目列表失败" + e.message);
  }
  // 如果题目不存在
  if (!question) {
    return <div>获取题目详情失败，请刷新重试</div>;
  }

  return (
    <div id={"questionPage"} className={"max-width-content"}>
      {/*@ts-ignore*/}
      <QuestionCard question={question}></QuestionCard>
    </div>
  );
}
